/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pkg_group5;

import java.sql.*;

/**
 *
 * @author prescotm
 */
public class Database {

    static final String driver = "com.mysql.jdbc.Driver";
    static final String url = "jdbc:mysql://localhost/";

    private String databaseName;
    protected Connection conn;

    public Database(String dbName)
    {
        databaseName = dbName;
        connectDatabase();
    }

    public void connectDatabase()
    {
        try
        {
            Class.forName(driver);
            conn = setupConnection();
        }
        catch (ClassNotFoundException cnf)
        {
            System.out.println("[Database() Error] - " + cnf.getMessage());
        }
    }
    
    private Connection setupConnection()
    {
        Connection sConn = null;
        try
        {
            sConn = DriverManager.getConnection(url + databaseName, "root", "password");
        }
        catch (SQLException sqle)
        {
            System.out.println("[setpConnection() Error] - " + sqle.getMessage());
        }
        
        return sConn;
    }

}
